﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RoboRace_Shared
{
    //Basic TILE object, TILEs are spaces on BOARD where ROBOTs can move onto.  All TILEs share the ability to execute
    //a behavior, but the behaviors themselves are different for each TILE.
    public interface ITile
    {
        Coordinate Coordinates { get; }
        void Behavior(ref Robot curRobot);
    }

    [Serializable]
    public abstract class Tile : ITile
    {
        private Coordinate _coordinate;

        public Tile(Coordinate coord)
        {
            if (coord != null)
            {
                _coordinate = coord;
            }
        }

        public Tile()
        {
            _coordinate = new Coordinate(0, 0);
        }

        public Coordinate Coordinates { get { return _coordinate; } }

        public virtual void Behavior(ref Robot curRobot)
        {

        }
    }

    //FLAG is a TILE in which the ROBOTs have to land on in squence.  BEHAVIOR should check ROBOTs active destination and
    //update if necessary.
    [Serializable]
    public class Flag : Tile
    {
        public Flag(Coordinate coord)
            : base(coord)
        {

        }

        public Flag()
            : base()
        {

        }

        public override void Behavior(ref Robot curRobot)
        {
            base.Behavior(ref curRobot);
        }
    }

    //REPAIR is a TILE in which will take away damage from a ROBOT.  BEHAVIOR should remove 1 damage from a ROBOT per turn;
    [Serializable]
    public class Repair : Tile
    {
        public Repair(Coordinate coord)
            : base(coord)
        {

        }

        public Repair()
            : base()
        {

        }

        public override void Behavior(ref Robot curRobot)
        {
            curRobot.Repair();
        }
    }

    //CONVEYOR is a TILE in which will move the ROBOT along a COMPASS path regardless of the ROBOT rotation.
    [Serializable]
    public class Conveyor : Tile
    {
        private COMPASS _direction;
        private int _distance;
        private Boolean _bolRotateMove;

        public Conveyor(Coordinate coord, COMPASS direction, int distance, Boolean RotateMove)
            : base(coord)
        {
            _direction = direction;
            _distance = distance;
            _bolRotateMove = RotateMove;
        }

        public Conveyor()
            : base()
        {
            _direction = COMPASS.WEST;
            _distance = 1;
            _bolRotateMove = false;
        }

        public override void Behavior(ref Robot curRobot)
        {
            //curRobot.Pushed(m_distance, m_direction);

            //Need to provide ability to verify that linked conveyors forming
            //a turn is handled appropriately.
        }
    }

    //PIT is a TILE in which will cause a ROBOT to die.
    [Serializable]
    public class Pit : Tile
    {
        public Pit(Coordinate coord)
            : base(coord)
        {

        }

        public Pit()
            : base()
        {

        }

        public override void Behavior(ref Robot curRobot)
        {
            curRobot.Die();
        }
    }

    //LASER is a TILE which will add 1 damage to the ROBOT.
    [Serializable]
    public class Laser : Tile
    {
        public Laser(Coordinate coord)
            : base(coord)
        {

        }

        public Laser()
            : base()
        {

        }

        public override void Behavior(ref Robot curRobot)
        {

        }
    }

    //CRUSHER is a TILE similiar to LASER, but will add 5 damage to the ROBOT.
    [Serializable]
    public class Crusher : Tile
    {
        public Crusher(Coordinate coord)
            : base(coord)
        {

        }

        public Crusher()
            : base()
        {

        }

        public override void Behavior(ref Robot curRobot)
        {

        }
    }

    //GEAR is a TILE that will change the ROBOTs rotation.
    [Serializable]
    public class Gear : Tile
    {
        public Gear(Coordinate coord)
            : base(coord)
        {

        }

        public Gear()
            : base()
        {

        }

        public override void Behavior(ref Robot curRobot)
        {

        }
    }
}
